package cn.tedu.boyou.search.query;

import cn.tedu.boyou.common.query.QueryObject;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;


@Getter
@Setter
@ToString
public class SearchQueryObject extends QueryObject{
    //条件的类型
    public static final int CONDITION_TYPE_ABROAD = 0;  //国外的
    public static final int CONDITION_TYPE_UN_ABROAD = 1;  //国内的
    public static final int CONDITION_TYPE_THEME = 2;   //主题的

    private String orderBy = "viewnum";//排序
    private int type = -1; //条件类型: 省份，id 国家id 主题id      //关键字搜索的时候，也可以用于区分不同的类别
    private int typeValue = -1; //条件值

    private Long destId = -1L;    //目的地id
    public Pageable getPageable(){
        PageRequest of = PageRequest.of(super.getCurrentPage() - 1, super.getPageSize(), Sort.Direction.DESC, orderBy);
        return of;
    }
    public Pageable getPageableWithoutSort(){
        PageRequest of = PageRequest.of(super.getCurrentPage() - 1, super.getPageSize());
        return of;
    }
}
